<template>
  <view class="method-selector">
    <text class="label">起卦方式</text>
    <view class="options">
      <view
        v-for="item in methods"
        :key="item.value"
        class="option"
        :class="{ active: modelValue === item.value }"
        @tap="selectMethod(item)"
      >
        <text>{{ item.label }}</text>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: 'MethodSelector',
  
  props: {
    modelValue: {
      type: String,
      default: 'manual'
    }
  },
  
  emits: ['update:modelValue', 'change'],
  
  setup(props, { emit }) {
    const methods = [
      { label: '手动起卦', value: 'manual' },
      { label: '在线起卦', value: 'online' }
    ]
    
    const selectMethod = (item) => {
      emit('update:modelValue', item.value)
      emit('change', item)
    }
    
    return {
      methods,
      selectMethod
    }
  }
}
</script>

<style lang="scss" scoped>
.method-selector {
  margin-bottom: 30rpx;
  
  .label {
    font-size: 28rpx;
    color: #333;
    margin-bottom: 16rpx;
    display: block;
  }
  
  .options {
    display: flex;
    gap: 20rpx;
    
    .option {
      flex: 1;
      height: 80rpx;
      display: flex;
      align-items: center;
      justify-content: center;
      background-color: #f7f7f7;
      border-radius: 8rpx;
      font-size: 28rpx;
      color: #333;
      
      &.active {
        background-color: #3872FE;
        color: #fff;
      }
    }
  }
}
</style>